﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;




namespace plagiat_tp
{
    public partial class Main : Form
    {
        TextFunctions tf;
        string[] SourceCS;

        public Main()
        {
            InitializeComponent();
        }
        struct vivod {
           public string adressSourse;
           public string[] adressFind;
           public string[] Procent;
           public int shingle;
        }


        private void настройкаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            (new History()).Show();
        }

        private void справкаToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            (new Spravka()).Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SourceCS = tf.getSourceTextParam(richTextBox1, address);
            
        }

        private void button1_Click(object sender, EventArgs e)
        {

            tf.getArrOfFiles(listBox1);

        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {

            tf.GetTextFromDoubleClick(richTextBox2, listBox1);
            
        }

        private void Main_Load(object sender, EventArgs e)
        {
            tf = new TextFunctions();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            PlagiatFinder pf = new PlagiatFinder();            
            pf.ViewResult(listBox1,SourceCS);
            TextFunctions tf = new TextFunctions();
            vivod vd;
            vd.adressSourse = address.Text.ToString();
            vd.adressFind = new string[listBox1.Items.Count];
            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                 vd.adressFind[i] = listBox1.Items[i].ToString();
            }
            vd.Procent= pf.ViewResult(listBox1, SourceCS);
            vd.shingle= 4;

            for (int i = 0; i < listBox1.Items.Count; i++)
            {
                dataGridView1.Rows.Add(vd.adressSourse ,  vd.adressFind[i], vd.Procent[i],vd.shingle);
            }
              
            
        }

             private void выходToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

             private void listBox1_KeyUp(object sender, KeyEventArgs e)
             {
                 if (e.KeyCode  == Keys.Delete)
                 {
                     listBox1.Items.Remove(listBox1.SelectedItem);
                     
                 }    
             }

             private void обновитьToolStripMenuItem_Click(object sender, EventArgs e)
             {
                 richTextBox1.Clear();
                 richTextBox2.Clear();
                 listBox1.Items.Clear();
                 dataGridView1.Rows.Clear();
             }

        

       

        
}  
}

       
      
        




    


